package com.itheima.health.service.impl;

import com.itheima.health.dao.MenuMapper;
import com.itheima.health.pojo.Menu;
import com.itheima.health.service.MenuService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Slf4j
@DubboService
public class MenuServiceImpl implements MenuService {
    @Autowired
    private MenuMapper menuMapper;

    /**
     * @Author: 位帅帅
     * @Date: 21:27 2021/1/12
     * @Params: []
     * @RerurnType: java.util.List<com.itheima.health.pojo.Menu>
     * @Description: 查询所有套餐
    */
    @Override
    public List<Menu> findAll() {
        Menu queryMenu = new Menu();
        queryMenu.setLevel(1);
        List<Menu> menuList = menuMapper.select(queryMenu);
        for (Menu menu : menuList) {
            Menu queryChildMenu = new Menu();
            queryChildMenu.setParentMenuId(menu.getId());
            List<Menu> childMenuList = menuMapper.select(queryChildMenu);
            menu.setChildren(childMenuList);
        }
        return menuList;
    }
}
